﻿@model MvcApplication6.Models.HomeModel
@using MvcApplication6.Models
@using MvcPaging
@using MvcApplication6.common
@if (Model.TotalRecord > 0)
{
    if (Model.ProductListModel.Count > 0)
    {
             <div class="pr-head">
                 <span>@Model.TitleMenu</span>
                 
                 
             </div>
    
                <ul class="pr-list" id="list1">
   
                     @foreach (var product in Model.ProductListModel)
                     {
                        <li class="pr-item">
                                 @*@Ajax.ImageActionLink(
                                 "../../Upload/Images/" + @product.Image,
                                "",
                                 "ProductDetail",
                                new
                                {
                                    LevelMenu = @Model.LevelMenu,
                                    Id = @product.Id,
                                    MenuId1 = @Model.MenuId1,
                                    MenuId2 = @Model.MenuId2,
                                    MenuId3 = @Model.MenuId3
                                },
                                new AjaxOptions
                                {
                                    HttpMethod = "GET",
                                    InsertionMode = InsertionMode.Replace,
                                    UpdateTargetId = "listProduct",
                                    OnSuccess = "myonsuccessCallServer"
                                },
                                   new { @class = "pr-img" }
                                )*@

                              @*   <a href="@Url.Action("ProductDetail"
                                            , new
                                            {
                                                LevelMenu = @Model.LevelMenu,
                                                Ids = @product.Id,
                                                MenuId1 = @Model.MenuId1,
                                                MenuId2 = @Model.MenuId2,
                                                MenuId3 = @Model.MenuId3
                                            }
                                         )"
                                >
                                    <img class = "pr-img" src="../../Upload/Images/@product.Image"/>
                                </a>*@

                                <a href="/Home/ProductDetail/1/@Model.LevelMenu/@product.Id/@Model.MenuId1/@Model.MenuId2/@Model.MenuId3/@product.Name">
                                    <img class = "pr-img" src="http://aptechpro.vn/Upload/Images/@product.Image"/>
                                </a>

				                @*<div class="pr-img" style="background-image: url(../../Upload/Images/@product.Image)"></div>*@
                                @if (@product.ProsalesFlag == 1 || @product.Sale > 0)
                                {
                                    <div class="buy-tag">-@product.Sale%</div>
                                }
                                
			                <div class="pr-info">
                             @if (Session["checkLoginAbcuser"] != null)
                             {

                                 if (Model.LevelMenu == 2)
                                 {
                                    <span class="pr-name">@product.Name || @product.Position2</span>
                                 }

                                 if (Model.LevelMenu == 3)
                                 {
                                    <span class="pr-name">@product.Name || @product.Position3</span>
                                 }

                                 if (Model.LevelMenu == 1)
                                 {
                                    <span class="pr-name">@product.Name || @product.Position1</span>
                                 }

                                 if (Model.LevelMenu == 0)
                                 {
                                     if (Model.ProductFlag == 1)
                                     {
                                    <span class="pr-name">@product.Name || @product.Position4</span>
                                     }
                                     else if (Model.ProductFlag == 2)
                                     {
                                         <span class="pr-name">@product.Name || @product.Position5</span>
                                     }
                                     else if (Model.ProductFlag == 3)
                                     {
                                           <span class="pr-name">@product.Name || @product.Position6</span>
                                
                                     }
                                     else if (Model.ProductFlag == 0)
                                     {
                                           <span class="pr-name">@product.Name</span>
                                
                                     }
                                 }


                             }
                             else
                             {
                                <span class="pr-name">@product.Name</span>
                             }
                               
                                
				                
				                <span class="pr-desc">Xuất xứ: @product.MakeIn </span>
                                <span class="pr-desc">Bảo hành: @product.Warranty </span>

                                @if (product.ProsalesFlag == 1 || @product.Sale > 0)
                                {
                                     <span class="pr-desc" style="text-decoration: line-through;">Giá chính hãng @FormatStringNumber.FormatString(@product.Price.ToString()) </span>
                                }
                                else
                                {
                                     <span class="pr-desc-red">@product.CallToSale</span>
                                }

				                <span class="pr-price">

                                    


                                     @*@Ajax.ActionLink(
                                        "Giá:" + @FormatStringNumber.FormatString(((@product.Price * (100 - @product.Sale)) / 100).ToString()) + "VNĐ",
                                        "ProductDetail",
                                        new
                                        {
                                            LevelMenu = @Model.LevelMenu,
                                            Id = @product.Id,
                                            MenuId1 = @Model.MenuId1,
                                            MenuId2 = @Model.MenuId2,
                                            MenuId3 = @Model.MenuId3
                                        },
                                        new AjaxOptions
                                        {
                                            HttpMethod = "GET",
                                            InsertionMode = InsertionMode.Replace,
                                            UpdateTargetId = "listProduct",
                                            OnSuccess = "myonsuccessCallServer"
                                        }
                                     )*@

                                 @*   @Html.ActionLink("Giá:" + @FormatStringNumber.FormatString(((@product.Price * (100 - @product.Sale)) / 100).ToString()) + "VNĐ"
                                    , "ProductDetail"
                                    , new
                                    {
                                        LevelMenu = @Model.LevelMenu,
                                        Ids = @product.Id,
                                        MenuId1 = @Model.MenuId1,
                                        MenuId2 = @Model.MenuId2,
                                        MenuId3 = @Model.MenuId3
                                    }
                                    , null)*@

                                 @if (product.ProsalesFlag == 1 || @product.Sale > 0)
                                 {
                                        <a href="/Home/ProductDetail/1/@Model.LevelMenu/@product.Id/@Model.MenuId1/@Model.MenuId2/@Model.MenuId3/@product.Name">
                                        Giảm còn: @FormatStringNumber.FormatString(((@product.Price * (100 - @product.Sale)) / 100).ToString()) VNĐ
                                        </a>
                                 }
                                 else
                                 {
                                        <a href="/Home/ProductDetail/1/@Model.LevelMenu/@product.Id/@Model.MenuId1/@Model.MenuId2/@Model.MenuId3/@product.Name">
                                            Giá: @FormatStringNumber.FormatString(((@product.Price * (100 - @product.Sale)) / 100).ToString()) VNĐ
                                        </a>
                                 }

                                </span>
                                 @if (Session["checkLoginAbcuser"] != null)
                                 { 
                                           @*<a  href="Admin/AddProduct?ProductId=@product.Id" >Sửa</a>*@
                                     
                                            @Html.ActionLink("|Sửa",
                                                  "AddProduct",   // <-- ActionMethod
                                                    "Admin",  // <-- Controller Name.
                                                    new
                                                    {
                                                        ProductId = @product.Id
                                                    }, // <-- Route arguments.
                                                    null
                                                    )

                                             @Ajax.ActionLink(
                                                    "Xóa",
                                                    "DeleteProduct",
                                                    new
                                                    {
                                                        Id = @product.Id,
                                                        LevelMenu = @Model.LevelMenu,
                                                        page = @Model.CurrentPage,
                                                        IdCe = @Model.ProductId,
                                                        TitleMenu = @Model.TitleMenu,
                                                        Flag = @Model.ProductFlag,
                                                        MenuId1 = @Model.MenuId1,
                                                        MenuId2 = @Model.MenuId2,
                                                        MenuId3 = @Model.MenuId3

                                                    },
                                                    new AjaxOptions
                                                    {
                                                        HttpMethod = "GET",
                                                        InsertionMode = InsertionMode.Replace,
                                                        UpdateTargetId = "listProduct",
                                                        OnBegin = "myonbegin",
                                                        OnSuccess = "myonsuccess",
                                                        OnFailure = "myonfailure"
                                                    }
                                                 )     
                                 }
                                 
                                
			                </div>
		                </li>
    
                     }	
	            </ul>
                     if (Model.TotalRecord > 0)
                     { 
                    <ul>
                    @Html.Raw(Ajax.Pager(
                            new Options
                            {
                                PageSize = 20,
                                TotalItemCount = Model.TotalRecord,
                                CurrentPage = Model.CurrentPage,
                                ItemTexts = new ItemTexts() { Next = "Next", Previous = "Previous", Page = "P" },
                                ItemIcon = new ItemIcon() { First = "icon-backward", Previous = "icon-chevron-left", Next = "icon-chevron-right", Last = "icon-forward" },
                                TooltipTitles = new TooltipTitles() { Next = "Next page", Previous = "Previous page", Page = "Page {0}." },
                                Size = Size.normal,
                                Alignment = Alignment.centered,
                                IsShowControls = true,
                                IsShowFirstLast = true,
                                IsShowPages = true,
                                CssClass = ""
                            },
                            new AjaxOptions
                            {
                                UpdateTargetId = "listProduct",
                                OnBegin = "beginPaging",
                                OnSuccess = "myonsuccessCallServer",
                                OnFailure = "failurePaging"
                            }, new { controller = "Home", action = "PagingSearch", nameSearch = @Model.NameSearch }))
	                </ul>
                
                     }

    }
    else
    { 
            <div class="pr-head"><span>Không Có Sản Phẩm</span>
             </div>
            
    }


}
else
{ 
    <div class="pr-head"><span>Không Có Sản Phẩm</span>
     </div>
}

